package com.pro.staffmanage.mapper;

import com.pro.staffmanage.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Set;

//  也可以在入口类Application上填注解@MapperScan("com.example.mybatis.mapper"), 相当于springmvc的扫描包
@Repository
@Mapper
public interface UserMapper{

    List<User> queryAllUser();

    User queryUserById(@Param("id") Integer id);

    Integer addUser(User user);

    Integer updateUser(User user);

    Integer deleteUser(@Param("id") Integer id);

    Set<GrantedAuthority> getAuthorities(@Param("id") int id);

    Integer addAuthorities(@Param("uid") int uid,@Param("rid") int rid);

    Integer updateAuthorities(@Param("uid") int uid,@Param("rid") int rid);

    Integer updatePassword(@Param("username") String username, @Param("password") String newPassword);

    User loadUserByUsername(@Param("username") String username) throws UsernameNotFoundException;

}